import java.util.Scanner;

public class ThreadDemo19 {
    private volatile static int flag = 0;
    public static void main(String[] args) {
        Thread t = new Thread(() ->{
           while (flag == 0){
               //什么都不做
           }
            System.out.println("t1 线程结束");
        });
        Thread t1 = new Thread(() ->{
            System.out.println("请输入flag的值：");
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });
        t.start();
        t1.start();
    }
}
